﻿<UserControl x:Class="SilverlightHVP.View.ItemsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:this="clr-namespace:SilverlightHVP.View;assembly=SilverlightHVP.View"

    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400"
    >
    <UserControl.Resources>
        <Style x:Key="ListBoxStyle1" TargetType="ListBox">
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"/>
            <Setter Property="ItemTemplate">
                <Setter.Value>
                    <DataTemplate>
                            <Grid>
                     <StackPanel
                        Width="150"
                        Height="120"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top">
                        <Image Source="{Binding Image}" Height="90" Width="150" Stretch="Fill"/>
                        <TextBlock Text="{Binding TextToDisplay}" Style="{StaticResource StdText}" FontSize="16" Foreground="White" VerticalAlignment="Bottom" />
                     </StackPanel>
                  </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="ListBoxItem" x:Key="ListBoxItemStyle1">
            <Setter Property="Padding" Value="0" />
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="VerticalContentAlignment" Value="Top" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="TabNavigation" Value="Local" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Grid Background="{TemplateBinding Background}" Margin="0,0,0,10">
                            <vsm:VisualStateManager.VisualStateGroups>
                                <vsm:VisualStateGroup x:Name="CommonStates">
                                    <vsm:VisualState x:Name="Normal" />
                                    <vsm:VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="fillColor" Storyboard.TargetProperty="Opacity" Duration="0" To="0.5"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="Opacity" Duration="0" To=".55" />
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                                <vsm:VisualStateGroup x:Name="SelectionStates">
                                    <vsm:VisualState x:Name="Unselected" />
                                    <vsm:VisualState x:Name="Selected">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="fillColor2" Storyboard.TargetProperty="Opacity" Duration="0" To="0"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                                <vsm:VisualStateGroup x:Name="FocusStates">
                                    <vsm:VisualState x:Name="Focused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility" Duration="0">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Unfocused"/>
                                </vsm:VisualStateGroup>
                            </vsm:VisualStateManager.VisualStateGroups>
                            
                            <ContentPresenter
                              x:Name="contentPresenter"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              Margin="{TemplateBinding Padding}"
                              Cursor="Hand"
                             />
                            
                            <!-- mouse over color -->
                            <Rectangle x:Name="fillColor" Opacity="0" Stroke="White" StrokeThickness="0" IsHitTestVisible="False" RadiusX="1" RadiusY="1"/>
                            
                            <!-- Selected Color -->
                            <Rectangle x:Name="fillColor2" Opacity="1" Fill="#66000000" IsHitTestVisible="False" RadiusX="1" RadiusY="1"/>
                            <Rectangle x:Name="FocusVisualElement" Opacity="0" Stroke="#FFFFFF" StrokeThickness="1" Visibility="Collapsed" RadiusX="1" RadiusY="1" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot" Margin="10">
      <this:ScrollBox>
         <ListBox
            Name="ItemsList"
            Background="Transparent"
            Style="{StaticResource ListBoxStyle1}"
            ItemContainerStyle="{StaticResource ListBoxItemStyle1}"
            BorderThickness="0"
            ItemsSource="{Binding Items}"
            SelectedItem="{Binding CurrentItem, Mode=TwoWay}">
         </ListBox>
      </this:ScrollBox>

   </Grid>
</UserControl>

<!--
   
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:si="clr-namespace:Expression.Samples.Interactivity;assembly=Expression.Samples.Interactivity"
     
         <i:Interaction.Triggers>
            <i:EventTrigger EventName="SelectionChanged">
               <si:CallDataMethod Method="HandleSelectionChanged" />
            </i:EventTrigger>
         </i:Interaction.Triggers>
   
   
   -->
